package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdPortMapper;
import com.diankangwo.factory.entity.TdPort;
import com.diankangwo.factory.service.TdPortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/** 端口接口实现类
 * Created by wuye on 2017/9/13.
 */
@Service("TdPortService")
public class TdPortServiceImpl implements TdPortService{


    @Autowired
    private TdPortMapper mapper;

    @Override
    public TdPort queryById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    /**
     * 根据条件获取端口列表
     * @param map
     * @return
     */
    @Override
    public List<TdPort> queryList(Map<String, Object> map) {
        return mapper.queryList(map);
    }

    /**
     * 根据条件获取端口总数
     * @param map
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return mapper.queryTotal(map);
    }

    /**
     * 保存一个端口
     * @param tdPort
     */
    @Override
    @Transactional
    public void save(TdPort tdPort) {
        mapper.insert(tdPort);
    }

    /**
     * 修改一个端口
     * @param tdPort
     * @return
     */
    @Override
    @Transactional
    public int update(TdPort tdPort) {
        return mapper.updateByPrimaryKey(tdPort);
    }

    /**
     * 删除一个端口
     * @param id
     */
    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    /**
     * 根据用户ID查询端口
     * @param userid
     * @return
     */
    @Override
    public List<TdPort> queryByUserId(int userid) {
        return mapper.queryByUserId(userid);
    }

    @Override
    public List<TdPort> queryListApply(Map<String, Object> map) {
        return mapper.queryListApply(map);
    }
}
